// Fill out your copyright notice in the Description page of Project Settings.


#include "Ability/BaseGameplayAbility.h"
#include "Abilities/Tasks/AbilityTask_PlayMontageAndWait.h"

UBaseGameplayAbility::UBaseGameplayAbility()
{
}


UAbilityTask_PlayMontageAndWait* UBaseGameplayAbility::CreatePlayMontageAndWaitProxy(
	FName TaskInstanceName,
	UAnimMontage* InMontageToPlay,
	float Rate /*= 1.f*/,
	FName StartSection /*= NAME_None*/,
	bool bStopWhenAbilityEnds /*= true*/, float AnimRootMotionTranslationScale /*= 1.f*/,
	float StartTimeSeconds /*= 0.f*/
)
{

	//使用基类AbilityTask_PlayMontageAndWait的方法CreatePlayMontageAndWaitProxy
	//类似于执行Super
	if (UAbilityTask_PlayMontageAndWait* InWait = UAbilityTask_PlayMontageAndWait::CreatePlayMontageAndWaitProxy(
		this,
		TaskInstanceName,
		InMontageToPlay,
		Rate,
		StartSection,
		bStopWhenAbilityEnds,
		AnimRootMotionTranslationScale,
		StartTimeSeconds))
	{
		/*//将以下这些方法绑定到基类的方法
		InWait->OnBlendOut.AddDynamic(this, &UBaseGameplayAbility::OnBlendOut);
		InWait->OnCompleted.AddDynamic(this, &UBaseGameplayAbility::OnCompleted);
		InWait->OnInterrupted.AddDynamic(this, &UBaseGameplayAbility::OnInterrupted);
		InWait->OnCancelled.AddDynamic(this, &UBaseGameplayAbility::OnCancelled);*/

		//激活

		return InWait;
	}

	return nullptr;
}


UAbilityTask_PlayMontageAndWait* UBaseGameplayAbility::PlayMontage(UAnimMontage* MontageToPlay,
                                                                   FName StartSection)
{
	return CreatePlayMontageAndWaitProxy(NAME_None, MontageToPlay, 1.f, StartSection);
}
